﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OJobListEasyUI.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.MacModel.OJobListEasyUI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../EasyUI/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../EasyUI/themes/icon.css" />
    <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-formatter_20140718.js"></script>
    <link href="../themes/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="../js/DWZ/jquery.autocomplete.js" type="text/javascript"></script>
    <script src="../js/DWZ/jquery.inputValue.js" type="text/javascript"></script>
    <style type="text/css">
        .datagrid-toolbar {
            background: none repeat scroll 0 0 #EFEFEF;
            border-bottom: 1px solid #CCCCCC;
            height: 56px !important;
            padding: 1px 2px;
        }

        .datagrid-toolbar-quicksearch {
            clear: both;
            line-height: 25px;
            border-bottom: 1px solid #99BBE8;
            margin-bottom: 2px;
        }
    </style>
    <script type="text/javascript">
        ///自适应宽高
        $(window).resize(function(){	
            $("#ojob_easyui_tabs").tabs({
                tabPosition:"bottom",
                width: '100%',
                height: $(parent.document).find(".tabsPageContent").height()-5> 0 ? $(parent.document).find(".tabsPageContent").height()-5  : 500,
            });
            $("#tab_list").datagrid({
                width: '100%',
                height: $("#ojob_easyui_tabs").height()-35
            }); 
        });
        //权限处理
        var $powers={
            "r查看":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.查看) %>,
            "r新增":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.新增) %>,
            "r修改":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>,
            "r删除":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.删除) %>,
            "r导出":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.导出) %>     
            };
        var $tabpanle2_isload=0;
        var $tabpanle3_isload=0;
        $(document).ready(function () {
             

            $("#ojob_easyui_tabs").tabs({
                tabPosition:"bottom",
                width: '100%',
                height: $(parent.document).find(".tabsPageContent").height()-5  > 0 ? $(parent.document).find(".tabsPageContent").height()-5  : 500,
                onSelect:function(title,index){
                    //  alert(index);
                    if(index==1 && $tabpanle2_isload==0)
                    {
                        InitGird2(); $tabpanle2_isload=1;
                    }
                    if(index==2 && $tabpanle3_isload==0)
                    {
                        InitGird3(); $tabpanle3_isload=1;
                    }

                }
            });  

            var $tab_toolbar=$("#tab_toolbar");
            $tab_toolbar.find("a").each(function(){
                var $per=$(this).attr("Permission");
                var pt= $powers[$per]==undefined || null?true:$powers[$per];
                $(this).linkbutton(pt?'enable': 'disable');
            })

            //自动完成
            $(".autocomplete").each(function () {
                var $this = $(this);
                var url = unescape($this.attr("autocompletehref"));
                $this.autocomplete(url);
            });
           $('#FTradeCatheringListEasyUIExportRZDialog').dialog({
				buttons:[{
				    text:'确定更新VIN生产日期',
					iconCls:'icon-ok',
                    plain:"true" ,
                    handler:function(){
                        var url = "sysAjaxDone.ashx?ajaxmethod=createvin2&SerialNumber=" + _vinSerialNumber+"&SCDATE="+ $('#FTradeCatheringListEasyUIExportRZDialog').find("input[name='vinSCDATE']").val();
                        top.ajaxTodo(url, "");                      
                        $('#FTradeCatheringListEasyUIExportRZDialog').dialog('close');
					}
				},{
					text:'关闭',
                    plain:"true" ,
					handler:function(){
						$('#FTradeCatheringListEasyUIExportRZDialog').dialog('close');
					}
				}]
           });

            //加载数据
            InitGird();           
        })
        //加载列表数据
        function InitGird() {
            $('#tab_list').datagrid({               
                url: location.href, //请求数据的页面
                sortName: 'JobId', //排序字段
                sortOrder: 'DESC', //排序类型
                idField: 'JobId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度    
                height: $("#ojob_easyui_tabs").height()-35,
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true, //是否只能选中一条
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                    { title: '机号', field: 'SerialNumber', width: 80, align:'center',formatter:function(value, row, index){
                        if(value==undefined)
                            return"";                            
                        return '<a href="#"  title="查看初加工物管制票" onclick="onControlTicketView(\''+value+'\'); return false;">'+value+'</a>';//事件处理
                    },styler:function(value, row, index){
                        if(row.ControlTicketNum>0)
                            return "color:red;"
                          
                        return "color:block;"
                    }
                    },
                    {title:'发动机号',field:'EngineNumber',width: 80,sortable:true },    
                    {title: '下线日期', field: 'DownlineDate', width: 70,formatter:formatterdate ,sortable: true}
                ]],
                columns: [[                   
                    { title: 'GPS安装', field: 'GPSIsSetUp', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "有"
                        else
                            return "<b style='color:red;'>无</b>"
                    }
                    },
                    {title: '入库日期', field: 'InStorageDate', width: 80,formatter:formatterdate ,sortable: true},
                    { title: 'GPS号码', field: 'GPSNumber', width: 80, sortable: true },
                    {title: 'SAP做帐出库日期', field: 'OnlineDate', width: 100,formatter:formatterdate,sortable: true},
                     {title: '工厂出货日期', field: 'OutDate', width: 90,formatter:formatterdate,sortable: true},
                    { title: 'GPS出库', field: 'GPSOutStorage', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },
                    { title: '整机库存', field: 'MACStock', width: 80, sortable: true ,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },       
                    { title: 'GPS库存', field: 'GPSStock', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;

                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    }, 
                    { title: '已销售未出厂', field: 'IsSellStorage', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;

                        if(value)
                            return "<b style='color:red;'>是</b>"
                        else
                            return "否"
                    }
                    }, 
                    { title: '出库形式', field: 'OutStockType', width: 100, sortable: true },  
                    { title: '经销商', field: 'AgentName', width: 100, sortable: true },  
                    { title: '最后出库地点', field: 'LastOutStack', width: 150, sortable: true },  
                    { title: '备注', field: 'Remark', width: 800, sortable: true },      
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "query" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: <%=numPerPage %>, //默认一页数据条数
                pageList:<%=SetnumPerPage() %>,
                rownumbers: true, //行号
                showFooter: true
            });

        }
        //显示已销售未出厂的机器数据
        function InitGird2() {
            $('#tab_list2').datagrid({               
                url: location.href, //请求数据的页面
                sortName: 'JobId', //排序字段
                sortOrder: 'DESC', //排序类型
                idField: 'JobId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度    
                height: $("#ojob_easyui_tabs").height()-35,
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true, //是否只能选中一条
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                    { title: '机号', field: 'SerialNumber', width: 80, align:'center',formatter:function(value, row, index){
                        if(value==undefined)
                            return"";                            
                        return '<a href="#"  title="查看初加工物管制票" onclick="onControlTicketView(\''+value+'\'); return false;">'+value+'</a>';//事件处理
                    },styler:function(value, row, index){
                        if(row.ControlTicketNum>0)
                            return "color:red;"
                          
                        return "color:block;"
                    }
                    },
                    {title:'发动机号',field:'EngineNumber',width: 80,sortable:true },    
                    {title: '下线日期', field: 'DownlineDate', width: 70,formatter:formatterdate ,sortable: true}
                ]],
                columns: [[                   
                    { title: 'GPS安装', field: 'GPSIsSetUp', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "有"
                        else
                            return "<b style='color:red;'>无</b>"
                    }
                    },
                    {title: '入库日期', field: 'InStorageDate', width: 80,formatter:formatterdate ,sortable: true},
                    { title: 'GPS号码', field: 'GPSNumber', width: 80, sortable: true },
                    {title: '出库日期', field: 'OnlineDate', width: 80,formatter:formatterdate,sortable: true},
                    { title: 'GPS出库', field: 'GPSOutStorage', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },
                    { title: '整机库存', field: 'MACStock', width: 80, sortable: true ,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },       
                    { title: 'GPS库存', field: 'GPSStock', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;

                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },  
                     { title: '已销售未出厂', field: 'IsSellStorage', width: 80, sortable: true,formatter:function(value, row, index){
                         if(row.JobId==undefined)
                             return value;

                         if(value)
                             return "<b style='color:red;'>是</b>"
                         else
                             return "否"
                     }
                     },
                    { title: '出库形式', field: 'OutStockType', width: 100, sortable: true },  
                    { title: '经销商', field: 'AgentName', width: 100, sortable: true },  
                    { title: '最后出库地点', field: 'LastOutStack', width: 150, sortable: true },  
                    { title: '备注', field: 'Remark', width: 800, sortable: true },      
                ]],               
                queryParams: { "action": "query2" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: <%=numPerPage %>, //默认一页数据条数
                pageList:<%=SetnumPerPage() %>,
                rownumbers: true, //行号
                showFooter: true
            });
        }
        //显示库存车超过两年的机器数据
        function InitGird3() {
            $('#tab_list3').datagrid({               
                url: location.href, //请求数据的页面
                sortName: 'JobId', //排序字段
                sortOrder: 'DESC', //排序类型
                idField: 'JobId', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度    
                height: $("#ojob_easyui_tabs").height()-35,
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true, //是否只能选中一条
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                    { title: '机号', field: 'SerialNumber', width: 80, align:'center',formatter:function(value, row, index){
                        if(value==undefined)
                            return"";                            
                        return '<a href="#"  title="查看初加工物管制票" onclick="onControlTicketView(\''+value+'\'); return false;">'+value+'</a>';//事件处理
                    },styler:function(value, row, index){
                        if(row.ControlTicketNum>0)
                            return "color:red;"
                          
                        return "color:block;"
                    }
                    },
                    {title:'发动机号',field:'EngineNumber',width: 80,sortable:true },    
                    {title: '下线日期', field: 'DownlineDate', width: 70,formatter:formatterdate ,sortable: true}
                ]],
                columns: [[                   
                    { title: 'GPS安装', field: 'GPSIsSetUp', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "有"
                        else
                            return "<b style='color:red;'>无</b>"
                    }
                    },
                    {title: '入库日期', field: 'InStorageDate', width: 80,formatter:formatterdate ,sortable: true},
                    { title: 'GPS号码', field: 'GPSNumber', width: 80, sortable: true },
                    {title: '出库日期', field: 'OnlineDate', width: 80,formatter:formatterdate,sortable: true},
                    { title: 'GPS出库', field: 'GPSOutStorage', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },
                    { title: '整机库存', field: 'MACStock', width: 80, sortable: true ,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;
                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },       
                    { title: 'GPS库存', field: 'GPSStock', width: 80, sortable: true,formatter:function(value, row, index){
                        if(row.JobId==undefined)
                            return value;

                        if(value)
                            return "是"
                        else
                            return "<b style='color:red;'>否</b>"
                    }
                    },  
                     { title: '已销售未出厂', field: 'IsSellStorage', width: 80, sortable: true,formatter:function(value, row, index){
                         if(row.JobId==undefined)
                             return value;

                         if(value)
                             return "<b style='color:red;'>是</b>"
                         else
                             return "否"
                     }
                     },
                    { title: '出库形式', field: 'OutStockType', width: 100, sortable: true },  
                    { title: '经销商', field: 'AgentName', width: 100, sortable: true },  
                    { title: '最后出库地点', field: 'LastOutStack', width: 150, sortable: true },  
                    { title: '备注', field: 'Remark', width: 800, sortable: true },      
                ]],               
                queryParams: { "action": "query3" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: <%=numPerPage %>, //默认一页数据条数
                pageList:<%=SetnumPerPage() %>,
                rownumbers: true, //行号
                showFooter: true
            });
        }
        /*每行的操作处理*/
        //查看初加工管制表
        function onControlTicketView(SerialNumber)
        {
            var rel = "viewOControlTicketList";
            var url = "MacModel/OControlTicketList.aspx?SerialNumber1=" + SerialNumber;
            var title = "查看初加工管制表";
            var options = { width: 850, height: 300, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            // top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
        
    </script>
    <script>
        //操作功能JS
       
        //打开高级查找窗口
        function onAdjSearch() {

            var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
            query.action = "query";
            $('#tab_list').datagrid("options").queryParams = query;
            $('#tab_list').datagrid('load');
            $("#tab_search").dialog("close");
            return false;

            $("#tab_search").dialog("open");
            $("#search-buttons").find("#btn_search").one("click", function () {
                

            });
        }
        //添加
        function onAddClick() {

            var rel = "OJobAdd";
            var url = "MacModel/OJobAdd.aspx";
            var title = "添加";
            var options = { width: 800, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.$.pdialog.open(url, rel, title, options);
            //top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
        var _vinSerialNumber="";
        function onVIN2()
        {
            _vinSerialNumber="";
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要更新VIN环保代码的记录');
                return false;
            }
            _vinSerialNumber = row.SerialNumber;
           
            $('#FTradeCatheringListEasyUIExportRZDialog').dialog('open');

            //$.messager.confirm('提示', '确定要生成此机器的环保代码吗？', function (r) {
            //    if (r) {
            //        var url = "sysAjaxDone.ashx?ajaxmethod=createvin&SerialNumber=" + SerialNumber;
            //        top.ajaxTodo(url, "");
            //        $("#tab_list").datagrid("load");
            //    }
            //});
        }
        function onVIN1()
        {
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要生成环保代码的记录');
                return false;
            }
            SerialNumber = row.SerialNumber;
            $.messager.confirm('提示', '确定要生成此机器的环保代码吗？', function (r) {
                if (r) {
                    var url = "sysAjaxDone.ashx?ajaxmethod=createvin&SerialNumber=" + SerialNumber;
                    top.ajaxTodo(url, "");
                    $("#tab_list").datagrid("load");
                }
            });
        }

        //修改，通过工具栏
        function onEditClick() {

            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要修改的记录');
                return false;
            }
            var SerialNumber = row.SerialNumber;
            var rel = "OJobEdit";
            var url = "MacModel/OJobEdit.aspx?SerialNumber=" + SerialNumber;
            var title = "修改";
            var options = { width: 800, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.$.pdialog.open(url, rel, title, options);
            // top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            $('#tab_list').datagrid('unselectAll')//取消选中,不然会直接选中上次的数据
            return false;
        }
       

        function onDelALLClick() {
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要删除的记录');
                return false;
            }
            var SerialNumber = row.SerialNumber;

            $.messager.confirm('提示', '确定要删除吗？', function (r) {
                if (r) {
                    var url = "sysAjaxDone.ashx?ajaxmethod=DeleteJob&SerialNumber=" + SerialNumber;
                    top.ajaxTodo(url, "");
                    $("#tab_list").datagrid("load");
                }
            });
        }
        function onExport() {
            var href = "<%= ExportExcelWebUrl%>/MacModel/ExportOJobList.aspx";
            top.window.open(href, "");
        }

    </script>
</head>
<body style="margin: 2px;">
    <div id="ojob_easyui_tabs" class="easyui-tabs" data-options="tabPosition:'bottom'">
        <div title="库存一览表" style="padding: 0px">
            <div id="tab_list"></div>
            <div id="tab_toolbar" style="padding: 2px; height: 80px!important;">
                <div id="tab_search" class="datagrid-toolbar-quicksearch">
                    <span style="line-height: 26px; width: 60px; font-weight: bold; color: Red;">快速查找:</span>
                    <select name="MachineType" onchange="onAdjSearch()">
                        <option value="" selected>所有机型</option>
                        <option value="135NS">135NS</option>
                        <option value="55NSL">55NSL</option>
                        <option value="55NSLGB3">55NSLGB3</option>
                        <option value="65NS">65NS</option>
                        <option value="65NSL">65NSL</option>
                        <option value="68NS">68NS</option>
                        <option value="68NSGB3">68NSGB3</option>
                        <option value="80NS">80NS</option>
                        <option value="80NSGB3">80NSGB3</option>
                        <option value="55NS">55NS</option>
                        <option value="60NS">60NS</option>
                        <option value="55VXL">55VXL</option>
                        <option value="80NC">80NC</option>
                        <option value="80NX">80NX</option>
                        <option value="40NS">40NS</option>
                        <option value="100NS">100NS</option>
                        <option value="100NSGB3">100NSGB3</option>
                        <option value="100NST">100NST</option>
                        <option value="100NSTGB3">100NSTGB3</option>
                        <option value="18VX">18VX</option>
                        <option value="55NSL经济款">55NSL经济款</option>
                        <option value="65NSL经济款">65NSL经济款</option>
                    </select>
                    &nbsp;
             <select name="CommonFiled" class="combox">
                 <option value="AgentName">经销商</option>
                 <option value="SerialNumber">机号</option>
                 <option value="PName">项目</option>
                 <option value="EngineNumber">发动机号</option>
                 <option value="GPSNumber">GPS号码</option>
             </select>
                    等于：<input name="CommonValue" type="text" value="" onblur="onAdjSearch()" />
                    &nbsp;
            备注：
                    <input name="Remark" type="text" value="" onblur="onAdjSearch()" />
                    &nbsp;<br />
                    出库时间从：
                    <input name="OnlineDateFrom" type="text" class="easyui-datebox" value="" onblur="onAdjSearch()" />
                    到：
                    <input name="OnlineDateTo" type="text" value="" class="easyui-datebox" onblur="onAdjSearch()" />
                    &nbsp;
           <input type="button" value="查找" onclick="onAdjSearch()" />
                </div>
                <div style="clear: both; vertical-align: middle;">
                    <a href="#" title="新增" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="return 　onAddClick()" permission="r新增">新增</a>
                    <a href="#" title="修改" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="return　onEditClick();" permission="r修改">修改</a>
                    <a href="#" title="删除" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="return　onDelALLClick();" permission="r删除">删除</a>
                    <a href="#" class="easyui-linkbutton" iconcls="icon-btnDown" plain="true" permission="r导出" onclick="return onExport()">导出</a>
                    <a href="#" class="easyui-linkbutton" iconcls="icon-btnDown" plain="true" permission="rVIN新增" onclick="return onVIN1()">1.生成VIN代码</a>
                    <a href="#" class="easyui-linkbutton" iconcls="icon-btnDown" plain="true" permission="rVIN修改" onclick="return onVIN2()">2.更新VIN生产日期</a>
                </div>
            </div>
             <div id="FTradeCatheringListEasyUIExportRZDialog" icon="icon-save" title="选择生产日期"  style="padding:5px;width:400px;height:180px;" modal="true" closed="true">		       
		        <p>
                    生产日期：<input  name="vinSCDATE" class="easyui-datebox" type="text" value="" />                   
                </p>		
	     </div>
        </div>
        

        <div title="已销售未出厂的机器" style="padding: 0px">
            <div id="tab_list2"></div>
        </div>
        <div title="库存车超过两年的机器" style="padding: 0px">
            <div id="tab_list3"></div>
        </div>
    </div>
</body>

</html>
